package com.distributedDataBase.service;

import com.distributedDataBase.mapper.ProductMapper;
import com.distributedDataBase.pojo.Product;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> listAll() {
        return productMapper.findAll();
    }

    @Override
    public PageInfo<Product> page(String name, Integer pageNum, Integer pageSize) {
        //设置分页的参数
        PageHelper.startPage(pageNum,pageSize);
        //调用mapper
        List<Product> list = productMapper.listAll(name);
        //创建PageInfo对象
        PageInfo<Product> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

}
